#ifndef NETWORKINTERFACE_H
#define NETWORKINTERFACE_H

#include <QTcpSocket>
#include <QTcpServer>
#include "basicinterface.h"

enum NetworkState
{
    WAITING_FOR_HELLO,
    WAITING_FOR_NAME,
    LOBBY_READY,
    GAME_READY
};

class NetworkInterface : public QObject, public BasicInterface
{
    Q_OBJECT

    QTcpSocket *Socket;
    NetworkState State;

public:
    static QTcpServer GameServer;

public:
    NetworkInterface(QTcpSocket *ConnectedSocket);

    static void StartServer();
    static void StopServer();

public slots:
    void ReceivedData();

signals:
    void TeamChanged(int CurrentTeam);
    void NameChanged(QString NewName);
    void Disconnected(NetworkInterface *Interface);

private:
    bool ReceivedLobbyData(QString data);
};

#endif // NETWORKINTERFACE_H
